<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('维修店档案列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <input id="storeState" name="storeState" value="1" type="hidden">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>店铺名称：</label>
                                <input id="storeName" type="text" name="storeName"/>
                            </li>
                            <li>
                                <label>联系人：</label>
                                <input id="storePerson" type="text" name="storePerson"/>
                            </li>
                            <li>
                                <label>联系方式：</label>
                                <input id="storePhone" type="text" name="storePhone"/>
                            </li>
                            <li>
                                <label>所属大区：</label>
                                <input id="agentName" type="text" name="agentName"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="col-sm-12 select-table table-bordered">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('zsyh:repairStore:edit')}]];
        var removeFlag = [[${@permission.hasPermi('zsyh:repairStore:remove')}]];
        var isRakerDatas = [[${@dict.getType('zsyh_yesno')}]];
        var partsCheckDatas = [[${@dict.getType('parts_check')}]];
        var prefix = ctx + "zsyh/repairStore";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                pageSize:7,
                modalName: "维修店档案",
                queryParams: function (params) {
                    var temp ={
                        storeState: '1',
                        storeName: $("#storeName").val(),
                        agentName: $("#agentName").val(),
                        storePerson: $("#storePerson").val(),
                        storePhone: $("#storePhone").val(),
                        pageSize: params.limit,
                        pageNum: params.offset / params.limit + 1,
                        pageOffset: params.offset
                    };
                    return temp;
                },
                columns: [{
                    field : 'Number',
                    title : '序号',
                    align: 'center',
                    width: 20,
                    formatter : function(value, row, index) {
                        var pageSize = $('#bootstrap-table').bootstrapTable('getOptions').pageSize;//通过表的#id 可以得到每页多少条
                        var pageNumber = $('#bootstrap-table').bootstrapTable('getOptions').pageNumber;//通过表的#id 可以得到当前第几页
                        return pageSize * (pageNumber - 1) + index + 1;//返回每条的序号： 每页条数 * （当前页 - 1 ）+ 序号
                    }
                },
                {
                    field: 'id',
                    title: '主键',
                    align: 'center',
                    visible: false
                },
                {
                    field: 'storeImage',
                    align: 'center',
                    title: '店铺门头',
                    formatter: function (value, row, index) {
                        return $.table.imageView(value);
                    }
                },
                {
                    field: 'storeName',
                    align: 'center',
                    title: '店铺名称'
                },
                {
                    field: 'storePageviews',
                    align: 'center',
                    title: '店铺浏览量'
                },
                {
                    field: 'storeAddress',
                    align: 'center',
                    title: '详细地址'
                },
                {
                    field: 'storePerson',
                    align: 'center',
                    title: '店铺联系人'
                },
                {
                    field: 'storePhone',
                    align: 'center',
                    title: '店铺手机号'
                },
                {
                    field: 'storeBusinessHours',
                    align: 'center',
                    title: '营业时间'
                },
                {
                    field: 'storeOpenYears',
                    align: 'center',
                    title: '开业年限'
                },
                {
                    field: 'storeLicense',
                    align: 'center',
                    title: '营业执照',
                    formatter: function (value, row, index) {
                        return $.table.imageView(value);
                    }
                },{
                        field: 'agentName',
                        align: 'center',
                        title: '所属大区'
                    },
                    {
                        field: 'isRaker',
                        align: 'center',
                        title: '订单管理人',
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(isRakerDatas, value);
                        }
                    },
                    {
                        field: 'isAppraisal',
                        align: 'center',
                        title: '配件鉴定权',
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(partsCheckDatas, value);
                        }
                    },
                    {
                        field: 'isDiamond',
                        align: 'center',
                        title: '星级店铺',
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(isRakerDatas, value);
                        }
                    },

                {
                    field: 'storeStateName',
                    align: 'center',
                    title: '状态'
                },
                    {
                        field: 'createTime',
                        align: 'center',
                        title: '申请时间'
                    },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '"  style="margin: 0 3px;" href="javascript:void(0)" onclick="viewRepairStore(\'' + row.id + '\')"><i class="fa fa-edit"></i>查看详情</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" style="margin: 0 3px;" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        if(row.storeStateName == "待审核"){
                            actions.push('<a style="margin-left: 3px;background-color: white;border-color: orangered;color: orangered;font-weight: bolder" class="btn btn-info btn-xs \' + removeFlag + \'" href="javascript:void(0)" onclick="checkStore(\'' + row.id + '\')"><i class="fa fa-check"></i>去审核</a> ');
                        }
                        /*actions.push('<a style="margin-left: 3px;background-color: white;border-color: #e23fff;color: #e23fff;font-weight: bolder" class="btn btn-info btn-xs \' + removeFlag + \'" href="javascript:void(0)" onclick="viewStoreCategory(\'' + row.id + '\')"><i class="fa fa-search"></i>查看服务类目</a> ');*/
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        function viewRepairStore(id) {
            var url = ctx+"zsyh/repairStore/viewRepairStore/"+id;
            layer.open({
                type: 2,
                area: ['1200px', '800px'],
                fix: false,
                //不固定
                maxmin: true,
                shade: 0.3,
                title: "查看详情",
                content:  url,
                closeBtn: 1,
                // 弹层外区域关闭
                shadeClose: true,
                end: function(){
                    //location.reload();
                },
                cancel: function(index) {
                    //location.reload();
                }
            });
        }

        function viewStoreCategory(id) {
            var url = ctx+"zsyh/storeCategory/viewStoreCategory?storeId="+id;
            layer.open({
                type: 2,
                area: ['1200px', ($(window).height()-50) + 'px'],
                fix: false,
                //不固定
                maxmin: true,
                shade: 0.3,
                title: "查看服务类目",
                content:  url,
                closeBtn: 1,
                // 弹层外区域关闭
                shadeClose: true,
                end: function(){
                    //location.reload();
                },
                cancel: function(index) {
                    //location.reload();
                }
            });
        }

        function closePartsCheck(id) {
            $.modal.confirm("确认要强制关闭该店铺鉴定权吗？", function() {
                $.operate.post(prefix + "/closePartsCheck", { "id":id,"type":"1"});
            })
        }

        function openPartsCheck(id) {
            $.modal.confirm("确认要打开该店铺鉴定权吗？", function() {
                $.operate.post(prefix + "/closePartsCheck", { "id":id,"type":"2"});
            })
        }

        function checkStore(id) {
            var url = ctx+"zsyh/repairStore/checkStore/"+id;
            layer.open({
                type: 2,
                area: ['1200px', '800px'],
                fix: false,
                //不固定
                maxmin: true,
                shade: 0.3,
                title: "审核店铺",
                content:  url,
                /*closeBtn: 1,*/
                // 弹层外区域关闭
                shadeClose: true,
                yes: function(){
                    $.modal.alertWarning("审核完成");
                    var $tableFlows = $('#bootstrap-table');
                    var pg = $tableFlows.bootstrapTable('getOptions').pageNumber;  //获取当前页码
                    // 跳转到对应的页面
                    $tableFlows.bootstrapTable('selectPage', parseInt(pg));
                },
                cancel: function(index) {
                    //location.reload();
                }
            });
        }

        function topStore(id) {
            $.modal.confirm("确认要设置该店铺为星级店铺？", function() {
                $.operate.post(ctx+"zsyh/repairStore/topStore", { "id":id});
            });
        }

        function viewCheckParts(id) {
            var url = ctx+"zsyh/partsCheck/viewPartsCheck?storeId="+id;
            layer.open({
                type: 2,
                area: ['1200px', ($(window).height()-50) + 'px'],
                fix: false,
                //不固定
                maxmin: true,
                shade: 0.3,
                title: "查看鉴定权产品",
                content:  url,
                closeBtn: 1,
                // 弹层外区域关闭
                shadeClose: true,
                end: function(){
                    //location.reload();
                },
                cancel: function(index) {
                    //location.reload();
                }
            });
        }

    </script>
</body>
</html>